# Contributor: Siva Mahadevan <me@svmhdvn.name>
# Maintainer: Siva Mahadevan <me@svmhdvn.name>
pkgname=watchmate
pkgver=0.5.2
pkgrel=0
pkgdesc="Companion app for InfiniTime-powered PineTime smart watch"
url="https://github.com/azymohliad/watchmate"
# s390x: https://github.com/nix-rust/nix/issues/1968
# loongarch64: nix crate fails to build
arch="all !s390x !loongarch64"
license="GPL-3.0-only"
makedepends="
	cargo
	cargo-auditable
	dbus-dev
	gdk-pixbuf-dev
	graphene-dev
	gtk4.0-dev
	libadwaita-dev
	openssl-dev
	pango-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/azymohliad/watchmate/archive/refs/tags/v$pkgver.tar.gz"
options="net" # needed for downloading dependencies

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --release --frozen
}

package() {
	local appid="io.gitlab.azymohliad.WatchMate"
	install -Dm755 target/release/"$pkgname" -t "$pkgdir"/usr/bin/
	install -Dm644 "assets/$appid.desktop" -t "$pkgdir/usr/share/applications/"
	install -Dm644 "assets/$appid.gschema.xml" -t "$pkgdir/usr/share/glib-2.0/schemas/"
	install -Dm644 "assets/$appid.metainfo.xml" -t "$pkgdir/usr/share/metainfo/"
	install -Dm644 "assets/icons/$appid.svg" -t \
		"$pkgdir/usr/share/icons/hicolor/scalable/apps/"
	install -Dm644 "assets/icons/$appid-symbolic.svg" -t \
		"$pkgdir/usr/share/icons/hicolor/symbolic/apps/"
}

sha512sums="
5f6252c90ed3b11ee16e4d658457d4c733c98726867173e46b5613887546a7f7d4686a3c275e448f404b5ff93bd8998693f6b4eb57147fcc4bc4a34c8c739844  watchmate-0.5.2.tar.gz
"
